﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using tuwien.auto.eibclient;

namespace KNXFramework.KNXObjects.ValueObjects.Unsigned
{
    internal class AngleObjectValue : U8ObjectValue
    {
        public AngleObjectValue(string value) : base(value)
        {
            if (m_Value > 360)
                throw new ApplicationException("AngleObjectValue: Value must be between 0 and 360. Val : " + value);
            m_Value = (uint)(((int)(m_Value * 256 / 360)) % 256);
        }
        public AngleObjectValue(EIBBuffer buffer) : base(buffer)
        {
        }
        public override string ToString()
        {
            return ((float)m_Value * 360 / 256).ToString("#.####");
        }
    }
}
